package messages;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

import utils.XmlSerializationUtils;

public class CipheredMessage implements Convertible {

	private static final long serialVersionUID = 1L;
	
	private String _cipheredString;
	
	public CipheredMessage(){}
	
	public CipheredMessage(String cipheredMessage){
		_cipheredString = cipheredMessage;
	}

	public String getCipheredMessage(){
		return _cipheredString;
	}
	
	public Element convertToCanonic(Document doc) {
		Element el = doc.createElement("CipheredMessage");

		if (_cipheredString != null) {
			Element childEl = doc.createElement("CipheredString");
			childEl.setTextContent(_cipheredString);
			el.appendChild(childEl);
		}
		
		return el;
	}

	public Object convertFromCanonic(Element el) {
		this._cipheredString = XmlSerializationUtils.getTextValue(el, "CipheredString");
		
		return this;
	}
	
	
}
